#!/bin/sh

LUA=lua

echo "Starting server"
$LUA server.lua &
pids="$pids $!"
trap "kill $pids > /dev/null 2> /dev/null" 0

for((i=0;i<10;++i));do if test -r server.ior;then break;else sleep 1;fi;done

echo "Starting server proxy"
$LUA proxy.lua &
pids="$pids $!"
trap "kill $pids > /dev/null 2> /dev/null" 0

for((i=0;i<10;++i));do if test -r proxy.ior;then break;else sleep 1;fi;done

echo "Starting client"
$LUA client.lua 4.9 1 3 2.9

echo "Demo finished."
rm -f server.ior proxy.ior
